home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 3
/
Info_Mac_1994-01.iso
/
Development
/
Source
/
MSG Graphic Effects 1.0 Source
/
Spiral wipe.c
< prev
next >
Wrap
Text File
|
1993-08-23
|
3KB
|
89 lines
/*******************************************************************************
* Copyright © 1992-1993 Mark Pilgrim *
* *
* This file is provided as is, and may be freely distributed unaltered. This *
* message must accompany any copy of this file. This file may be used or *
* modified for use for a non-commercial product provided that appropriate *
* credit is given to the author named above. *
* Commercial use of this source code is prohibited. *
******************************************************************************/
#include "msg misc.h"
#include "msg timing.h"
#define BOXSIZE 20
#define CorrectTime 1
void SpiralGyra(GrafPtr);
/* Start in the topleft corner, facing downwards. Copy until you hit (a) the
edge of the screen, or (b) bits you've already copied. Then turn counter-
clockwise and do it again. */
void SpiralGyra(GrafPtr sourceGrafPtr)
{
int stop,sbottom,sleft,sright,iterrow,itercol,direction;
Rect source;
Boolean everyOther;
everyOther=FALSE;
stop=0;
sbottom=MAIN_WINDOW_HEIGHT/BOXSIZE-(MAIN_WINDOW_HEIGHT%BOXSIZE ? 0 : 1);
sleft=0;
sright=MAIN_WINDOW_WIDTH/BOXSIZE-(MAIN_WINDOW_WIDTH%BOXSIZE ? 0 : 1);
direction=3;
iterrow=stop;
itercol=sleft;
while ((stop<=sbottom)&&(sleft<=sright))
{
StartTiming();
source.top=iterrow*BOXSIZE; /* Yes, I know I should recode this */
source.bottom=source.top+BOXSIZE; /* to take out multiplication. */
source.left=itercol*BOXSIZE; /* If it matter that much to you, */
source.right=source.left+BOXSIZE; /* you do it. */
CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
&source, &source, 0, 0L);
switch (direction)
{
case 0: /* facing right */
if (itercol==sright)
{
sbottom--;
direction++;
iterrow--;
}
else itercol++;
break;
case 1: /* facing up */
if (iterrow==stop) /* that reads "s top," not "stop" */
{
sright--;
direction++;
itercol--;
}
else iterrow--;
break;
case 2: /* facing left */
if (itercol==sleft)
{
stop++;
direction++;
iterrow++;
}
else itercol--;
break;
case 3: /* facing down */
if (iterrow==sbottom)
{
sleft++;
direction=0;
itercol++;
}
else iterrow++;
break;
}
if (everyOther)
TimeCorrection(CorrectTime);
everyOther=!everyOther;
}
}